oil_price<- read.csv("/Users/apple/Desktop/Time series/oil_daily.csv", header=TRUE, stringsAsFactors=FALSE)
oil_price1 <- oil_price
names(oil_price)
## [1] "date" "price"
head(oil_price)
## date price
## 1 1/4/10 81.52
## 2 1/5/10 81.74
## 3 1/6/10 83.12
## 4 1/7/10 82.60
## 5 1/8/10 82.74
## 6 1/11/10 82.54
summary(oil_price)
## date price
## Length:1746 Min. : 26.21
## Class :character 1st Qu.: 55.56
## Mode :character Median : 86.68
## Mean : 79.08
## 3rd Qu.: 97.24
## Max. :113.39
oil_price.raw <- ts(oil_price$price, frequency = 365, start=c(2010))
plot(oil_price.raw)
Oil is daily priced, in order to make oil and goid prices in a same time frequency, applying “aggregate”" function to generate average prices of each month.
# Convert to date if not already
oil_price1$date <- as.Date(oil_price1$date, format = "%m/%d/%y")
# Get months
oil_price1$MonthYear <- format(oil_price1$date,format="%m/%Y")
# Aggregate oil_price on months and year and get mean
oil_monthly <- aggregate( oil_price$price ~ MonthYear , oil_price1 , mean )
We use the ts() function in R to store the data in a time series object.
library(zoo)
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
oil_monthly.sorted<-oil_monthly[order(as.yearmon(oil_monthly$MonthYear, format="%m/%Y")),]
oil_monthly.sorted.ts<-ts(oil_monthly.sorted$`oil_price$price`, frequency = 12, start=c(2010))
plot(oil_monthly.sorted.ts)
oil_monthly.sorted.ts.d<-decompose(oil_monthly.sorted.ts)
plot(oil_monthly.sorted.ts.d)
gold_price<- read.csv("/Users/apple/Desktop/Time series/gold_monthly.csv", header=TRUE, stringsAsFactors=FALSE)
names(gold_price)
## [1] "series_id" "date" "real" "nominal"
head(gold_price)
## series_id date real nominal
## 1 GOLDAMGBD228NLBM 1/1/10 1203.61 1078.50
## 2 GOLDAMGBD228NLBM 2/1/10 1235.70 1108.25
## 3 GOLDAMGBD228NLBM 3/1/10 1239.32 1115.50
## 4 GOLDAMGBD228NLBM 4/1/10 1307.79 1179.25
## 5 GOLDAMGBD228NLBM 5/1/10 1337.91 1207.50
## 6 GOLDAMGBD228NLBM 6/1/10 1369.06 1234.50
summary(gold_price)
## series_id date real nominal
## Length:83 Length:83 Min. :1082 Min. :1062
## Class :character Class :character 1st Qu.:1240 1st Qu.:1205
## Mode :character Mode :character Median :1338 Median :1311
## Mean :1427 Mean :1362
## 3rd Qu.:1640 3rd Qu.:1534
## Max. :1947 Max. :1825
gold_price.raw <- ts(gold_price$real, frequency = 12, start=c(2010))
plot(gold_price.raw)
gold_price.sorted<-gold_price[order(as.Date(gold_price$real, format="%m/%d/%Y", decreasing = FALSE)),]
gold_price.sorted.ts<-ts(gold_price.sorted$real, frequency = 12, start=c(2010))
gold_price.sorted.ts.d<-decompose(gold_price.sorted.ts)
plot(gold_price.sorted.ts.d)
SP500<- read.csv("/Users/apple/Desktop/Time series/sp500.csv", header=TRUE, stringsAsFactors=FALSE)
names(SP500)
## [1] "Date" "Open" "High" "Low" "Close" "Volume"
## [7] "Adj.Close"
head(SP500)
## Date Open High Low Close Volume Adj.Close
## 1 2016-11-01 2128.68 2204.80 2083.79 2204.72 4552212300 2204.72
## 2 2016-10-03 2164.33 2169.60 2114.72 2126.15 3672334700 2126.15
## 3 2016-09-01 2171.33 2187.87 2119.12 2168.27 3878265700 2168.27
## 4 2016-08-01 2173.15 2193.81 2147.58 2170.95 3451160800 2170.95
## 5 2016-07-01 2099.34 2177.09 2074.02 2173.60 3678454500 2173.60
## 6 2016-06-01 2093.94 2120.55 1991.68 2098.86 4157978100 2098.86
summary(SP500)
## Date Open High Low
## Length:83 Min. :1031 Min. :1112 Min. :1011
## Class :character 1st Qu.:1311 1st Qu.:1345 1st Qu.:1263
## Mode :character Median :1610 Median :1687 Median :1581
## Mean :1631 Mean :1677 Mean :1583
## 3rd Qu.:2000 3rd Qu.:2072 3rd Qu.:1934
## Max. :2173 Max. :2205 Max. :2148
## Close Volume Adj.Close
## Min. :1031 Min. :2.876e+09 Min. :1031
## 1st Qu.:1317 1st Qu.:3.588e+09 1st Qu.:1317
## Median :1631 Median :3.917e+09 Median :1631
## Mean :1643 Mean :3.991e+09 Mean :1643
## 3rd Qu.:2011 3rd Qu.:4.203e+09 3rd Qu.:2011
## Max. :2205 Max. :6.627e+09 Max. :2205
SP500.sorted<-SP500[order(as.Date(SP500$Date, format="%Y-%m-%d")),]
SP500.sorted.ts<-ts(SP500.sorted$Open,start=c(2010),frequency = 12)
plot(SP500.sorted.ts)
SP500.sorted.ts.d<-decompose(SP500.sorted.ts)
plot(SP500.sorted.ts.d)
combine <- cbind(oil_monthly.sorted.ts,gold_price.sorted.ts )
plot(combine)
combine2 <- cbind(gold_price.sorted.ts,SP500.sorted.ts )
plot(combine2)
oil.holt <- HoltWinters(oil_monthly.sorted.ts, gamma=FALSE)
oil.holt # to inspect the smoothing results
## Holt-Winters exponential smoothing with trend and without seasonal component.
##
## Call:
## HoltWinters(x = oil_monthly.sorted.ts, gamma = FALSE)
##
## Smoothing parameters:
## alpha: 1
## beta : 0.0268507
## gamma: FALSE
##
## Coefficients:
## [,1]
## a 45.3325000
## b -0.8708458
plot(oil.holt)
library(forecast)
## Loading required package: timeDate
## This is forecast 7.3
oil_monthly.holt.T <- HoltWinters(oil_monthly.sorted.ts, gamma=TRUE)
oil_monthly.holt.T
## Holt-Winters exponential smoothing with trend and additive seasonal component.
##
## Call:
## HoltWinters(x = oil_monthly.sorted.ts, gamma = TRUE)
##
## Smoothing parameters:
## alpha: 0.8593097
## beta : 0.03177809
## gamma: TRUE
##
## Coefficients:
## [,1]
## a 53.0984243
## b -0.3437656
## s1 -5.2410735
## s2 -3.5912350
## s3 -1.5577753
## s4 4.1039395
## s5 11.0032808
## s6 10.1882198
## s7 4.5330357
## s8 -1.3565296
## s9 -5.3204589
## s10 -6.9083825
## s11 -7.1912502
## s12 -7.7659243
oil_monthly.holt.F <- HoltWinters(oil_monthly.sorted.ts, gamma=FALSE)
oil_monthly.holt.F
## Holt-Winters exponential smoothing with trend and without seasonal component.
##
## Call:
## HoltWinters(x = oil_monthly.sorted.ts, gamma = FALSE)
##
## Smoothing parameters:
## alpha: 1
## beta : 0.0268507
## gamma: FALSE
##
## Coefficients:
## [,1]
## a 45.3325000
## b -0.8708458
oil_monthly.forecasts <- forecast.HoltWinters(oil_monthly.holt.T, h=12) # forecast 1 year (12 months)
plot.forecast(oil_monthly.forecasts)
oil_monthly.forecasts.F <- forecast.HoltWinters(oil_monthly.holt.F, h=12) # forecast 1 year (12 months)
plot.forecast(oil_monthly.forecasts.F)
oil_monthly.arima<-arima(oil_monthly.sorted.ts, c(0,0,0)) # this models is equivalent to ARMA(0,0,0)
oil_monthly.arima.forecasts1 <- forecast.Arima(oil_monthly.arima, h=12)
summary(oil_monthly.arima.forecasts1)
##
## Forecast method: ARIMA(0,0,0) with non-zero mean
##
## Model Information:
##
## Call:
## arima(x = oil_monthly.sorted.ts, order = c(0, 0, 0))
##
## Coefficients:
## intercept
## 79.1217
## s.e. 2.4970
##
## sigma^2 estimated as 517.5: log likelihood = -377.11, aic = 758.21
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 5.36289e-12 22.74847 19.57351 -12.27947 32.23877 1.178988
## ACF1
## Training set 0.9566265
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Dec 2016 79.12165 49.96832 108.275 34.53547 123.7078
## Jan 2017 79.12165 49.96832 108.275 34.53547 123.7078
## Feb 2017 79.12165 49.96832 108.275 34.53547 123.7078
## Mar 2017 79.12165 49.96832 108.275 34.53547 123.7078
## Apr 2017 79.12165 49.96832 108.275 34.53547 123.7078
## May 2017 79.12165 49.96832 108.275 34.53547 123.7078
## Jun 2017 79.12165 49.96832 108.275 34.53547 123.7078
## Jul 2017 79.12165 49.96832 108.275 34.53547 123.7078
## Aug 2017 79.12165 49.96832 108.275 34.53547 123.7078
## Sep 2017 79.12165 49.96832 108.275 34.53547 123.7078
## Oct 2017 79.12165 49.96832 108.275 34.53547 123.7078
## Nov 2017 79.12165 49.96832 108.275 34.53547 123.7078
plot(oil_monthly.arima.forecasts1)
oil_monthly.arima<-arima(oil_monthly.sorted.ts, c(0,1,0)) # this models is equivalent to ARMA(0,1,0)
oil_monthly.arima.forecasts2 <- forecast.Arima(oil_monthly.arima, h=12)
summary(oil_monthly.arima.forecasts2)
##
## Forecast method: ARIMA(0,1,0)
##
## Model Information:
##
## Call:
## arima(x = oil_monthly.sorted.ts, order = c(0, 1, 0))
##
##
## sigma^2 estimated as 31.51: log likelihood = -257.81, aic = 517.62
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -0.3965658 5.57924 4.253034 -0.9994152 6.123115 0.2561766
## ACF1
## Training set 0.2924773
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Dec 2016 45.3325 38.13896 52.52604 34.330929 56.33407
## Jan 2017 45.3325 35.15930 55.50570 29.773929 60.89107
## Feb 2017 45.3325 32.87292 57.79208 26.277220 64.38778
## Mar 2017 45.3325 30.94542 59.71958 23.329358 67.33564
## Apr 2017 45.3325 29.24725 61.41775 20.732240 69.93276
## May 2017 45.3325 27.71200 62.95300 18.384265 72.28074
## Jun 2017 45.3325 26.30018 64.36482 16.225079 74.43992
## Jul 2017 45.3325 24.98609 65.67891 14.215358 76.44964
## Aug 2017 45.3325 23.75188 66.91312 12.327787 78.33721
## Sep 2017 45.3325 22.58453 68.08047 10.542478 80.12252
## Oct 2017 45.3325 21.47422 69.19078 8.844417 81.82058
## Nov 2017 45.3325 20.41334 70.25166 7.221940 83.44306
plot(oil_monthly.arima.forecasts2)
oil_monthly.arima<-arima(oil_monthly.sorted.ts, c(1,1,0)) # this models is equivalent to ARMA(1,1,0)
oil_monthly.arima.forecasts3 <- forecast.Arima(oil_monthly.arima, h=12)
summary(oil_monthly.arima.forecasts3)
##
## Forecast method: ARIMA(1,1,0)
##
## Model Information:
##
## Call:
## arima(x = oil_monthly.sorted.ts, order = c(1, 1, 0))
##
## Coefficients:
## ar1
## 0.2947
## s.e. 0.1052
##
## sigma^2 estimated as 28.73: log likelihood = -254.07, aic = 512.15
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -0.2947291 5.327674 4.102864 -0.6688184 5.816437 0.2471313
## ACF1
## Training set 0.04029487
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Dec 2016 43.97450 37.10531 50.84368 33.4689822 54.48001
## Jan 2017 43.57424 32.33657 54.81191 26.3877035 60.76078
## Feb 2017 43.45627 28.74725 58.16529 20.9607642 65.95178
## Mar 2017 43.42150 25.82052 61.02248 16.5031200 70.33988
## Apr 2017 43.41125 23.30556 63.51694 12.6622534 74.16025
## May 2017 43.40823 21.07037 65.74610 9.2454188 77.57105
## Jun 2017 43.40734 19.03914 67.77554 6.1393963 80.67529
## Jul 2017 43.40708 17.16467 69.64949 3.2727777 83.54138
## Aug 2017 43.40700 15.41546 71.39855 0.5976291 86.21638
## Sep 2017 43.40698 13.76931 73.04465 -1.9199212 88.73388
## Oct 2017 43.40697 12.20991 74.60404 -4.3048179 91.11876
## Nov 2017 43.40697 10.72483 76.08911 -6.5760510 93.38999
plot(oil_monthly.arima.forecasts3)
gold.holt <- HoltWinters(gold_price.raw, gamma=FALSE)
gold.holt # to inspect the smoothing results
## Holt-Winters exponential smoothing with trend and without seasonal component.
##
## Call:
## HoltWinters(x = gold_price.raw, gamma = FALSE)
##
## Smoothing parameters:
## alpha: 0.7102502
## beta : 0.08119917
## gamma: FALSE
##
## Coefficients:
## [,1]
## a 1235.31271
## b -1.34542
plot(gold.holt)
library(forecast)
gold_price.holt.T <- HoltWinters(gold_price.sorted.ts, gamma=TRUE)
gold_price.holt.T
## Holt-Winters exponential smoothing with trend and additive seasonal component.
##
## Call:
## HoltWinters(x = gold_price.sorted.ts, gamma = TRUE)
##
## Smoothing parameters:
## alpha: 0.7863709
## beta : 0.05746769
## gamma: TRUE
##
## Coefficients:
## [,1]
## a 1217.093361
## b -3.806949
## s1 20.920450
## s2 47.766114
## s3 17.981576
## s4 -2.871595
## s5 -37.319790
## s6 -52.375053
## s7 -45.121574
## s8 -49.726875
## s9 -19.955056
## s10 -18.622747
## s11 -10.756628
## s12 -5.293361
gold_price.holt.F <- HoltWinters(gold_price.sorted.ts, gamma=FALSE)
gold_price.holt.F
## Holt-Winters exponential smoothing with trend and without seasonal component.
##
## Call:
## HoltWinters(x = gold_price.sorted.ts, gamma = FALSE)
##
## Smoothing parameters:
## alpha: 0.7102502
## beta : 0.08119917
## gamma: FALSE
##
## Coefficients:
## [,1]
## a 1235.31271
## b -1.34542
gold_price.forecasts <- forecast.HoltWinters(gold_price.holt.T, h=12) # forecast 1 year (12 months)
plot.forecast(gold_price.forecasts)
gold_price.forecasts.F <- forecast.HoltWinters(gold_price.holt.F, h=12) # forecast 1 year (12 months)
plot.forecast(gold_price.forecasts.F)
gold_price.arima<-arima(gold_price.sorted.ts, c(0,0,0)) # this models is equivalent to ARMA(0,0,0)
gold_price.arima.forecasts1 <- forecast.Arima(gold_price.arima, h=12)
summary(gold_price.arima.forecasts1)
##
## Forecast method: ARIMA(0,0,0) with non-zero mean
##
## Model Information:
##
## Call:
## arima(x = gold_price.sorted.ts, order = c(0, 0, 0))
##
## Coefficients:
## intercept
## 1426.7354
## s.e. 25.4003
##
## sigma^2 estimated as 53550: log likelihood = -569.64, aic = 1143.28
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -4.378693e-14 231.4077 201.665 -2.514454 14.07816 1.010266
## ACF1
## Training set 0.9296983
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Dec 2016 1426.735 1130.175 1723.296 973.1846 1880.286
## Jan 2017 1426.735 1130.175 1723.296 973.1846 1880.286
## Feb 2017 1426.735 1130.175 1723.296 973.1846 1880.286
## Mar 2017 1426.735 1130.175 1723.296 973.1846 1880.286
## Apr 2017 1426.735 1130.175 1723.296 973.1846 1880.286
## May 2017 1426.735 1130.175 1723.296 973.1846 1880.286
## Jun 2017 1426.735 1130.175 1723.296 973.1846 1880.286
## Jul 2017 1426.735 1130.175 1723.296 973.1846 1880.286
## Aug 2017 1426.735 1130.175 1723.296 973.1846 1880.286
## Sep 2017 1426.735 1130.175 1723.296 973.1846 1880.286
## Oct 2017 1426.735 1130.175 1723.296 973.1846 1880.286
## Nov 2017 1426.735 1130.175 1723.296 973.1846 1880.286
plot(gold_price.arima.forecasts1)
gold_price.arima<-arima(gold_price.sorted.ts, c(0,1,0)) # this models is equivalent to ARMA(0,1,0)
gold_price.arima.forecasts2 <- forecast.Arima(gold_price.arima, h=12)
summary(gold_price.arima.forecasts2)
##
## Forecast method: ARIMA(0,1,0)
##
## Model Information:
##
## Call:
## arima(x = gold_price.sorted.ts, order = c(0, 1, 0))
##
##
## sigma^2 estimated as 6451: log likelihood = -476, aic = 954
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.113176 79.83014 59.4592 -0.1280715 4.077489 0.2978685
## ACF1
## Training set -0.2041172
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Dec 2016 1211.8 1108.8718 1314.728 1054.3849 1369.215
## Jan 2017 1211.8 1066.2375 1357.362 989.1814 1434.419
## Feb 2017 1211.8 1033.5231 1390.077 939.1490 1484.451
## Mar 2017 1211.8 1005.9435 1417.656 896.9697 1526.630
## Apr 2017 1211.8 981.6455 1441.955 859.8091 1563.791
## May 2017 1211.8 959.6784 1463.922 826.2132 1597.387
## Jun 2017 1211.8 939.4775 1484.122 795.3187 1628.281
## Jul 2017 1211.8 920.6750 1502.925 766.5628 1657.037
## Aug 2017 1211.8 903.0153 1520.585 739.5546 1684.045
## Sep 2017 1211.8 886.3124 1537.288 714.0096 1709.590
## Oct 2017 1211.8 870.4257 1553.174 689.7131 1733.887
## Nov 2017 1211.8 855.2462 1568.354 666.4980 1757.102
plot(gold_price.arima.forecasts2)
gold_price.arima<-arima(gold_price.sorted.ts, c(1,1,0)) # this models is equivalent to ARMA(1,1,0)
gold_price.arima.forecasts3 <- forecast.Arima(gold_price.arima, h=12)
summary(gold_price.arima.forecasts3)
##
## Forecast method: ARIMA(1,1,0)
##
## Model Information:
##
## Call:
## arima(x = gold_price.sorted.ts, order = c(1, 1, 0))
##
## Coefficients:
## ar1
## -0.2035
## s.e. 0.1079
##
## sigma^2 estimated as 6179: log likelihood = -474.26, aic = 952.52
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.275493 78.13319 59.67147 -0.1335595 4.097238 0.2989318
## ACF1
## Training set -0.0261233
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Dec 2016 1224.277 1123.5365 1325.017 1070.2079 1378.346
## Jan 2017 1221.737 1092.9491 1350.526 1024.7728 1418.702
## Feb 2017 1222.254 1068.2694 1376.239 986.7547 1457.754
## Mar 2017 1222.149 1046.9532 1397.345 954.2101 1490.088
## Apr 2017 1222.170 1027.9933 1416.348 925.2021 1519.139
## May 2017 1222.166 1010.7186 1433.614 898.7850 1545.547
## Jun 2017 1222.167 994.7543 1449.580 874.3693 1569.965
## Jul 2017 1222.167 979.8390 1464.495 851.5584 1592.775
## Aug 2017 1222.167 965.7900 1478.544 830.0724 1614.261
## Sep 2017 1222.167 952.4719 1491.862 809.7041 1634.629
## Oct 2017 1222.167 939.7812 1504.552 790.2954 1654.038
## Nov 2017 1222.167 927.6369 1516.697 771.7221 1672.611
plot(gold_price.arima.forecasts3)
SP500.holt <- HoltWinters(SP500.sorted.ts, gamma=FALSE)
SP500.holt # to inspect the smoothing results
## Holt-Winters exponential smoothing with trend and without seasonal component.
##
## Call:
## HoltWinters(x = SP500.sorted.ts, gamma = FALSE)
##
## Smoothing parameters:
## alpha: 0.8921297
## beta : 0.1030654
## gamma: FALSE
##
## Coefficients:
## [,1]
## a 2134.080159
## b 7.423096
plot(SP500.holt)
SP500.holt.T <- HoltWinters(SP500.sorted.ts, gamma=TRUE)
SP500.holt.T
## Holt-Winters exponential smoothing with trend and additive seasonal component.
##
## Call:
## HoltWinters(x = SP500.sorted.ts, gamma = TRUE)
##
## Smoothing parameters:
## alpha: 0.7699449
## beta : 0
## gamma: TRUE
##
## Coefficients:
## [,1]
## a 2176.1083139
## b 15.0439430
## s1 -18.2004106
## s2 -16.7897028
## s3 -28.6134342
## s4 47.9571311
## s5 81.2856492
## s6 72.7865210
## s7 70.1295594
## s8 15.3640992
## s9 0.8914555
## s10 -76.7993468
## s11 -103.0701627
## s12 -47.4283819
SP500.holt.F <- HoltWinters(SP500.sorted.ts, gamma=FALSE)
SP500.holt.F
## Holt-Winters exponential smoothing with trend and without seasonal component.
##
## Call:
## HoltWinters(x = SP500.sorted.ts, gamma = FALSE)
##
## Smoothing parameters:
## alpha: 0.8921297
## beta : 0.1030654
## gamma: FALSE
##
## Coefficients:
## [,1]
## a 2134.080159
## b 7.423096
SP500.forecasts <- forecast.HoltWinters(SP500.holt.T, h=12) # forecast 1 year (12 months)
plot.forecast(SP500.forecasts)
SP500.forecasts.F <- forecast.HoltWinters(SP500.holt.F, h=12) # forecast 1 year (12 months)
plot.forecast(SP500.forecasts.F)
SP500.arima<-arima(SP500.sorted.ts, c(0,0,0)) # this models is equivalent to ARMA(0,0,0)
SP500.arima.forecasts1 <- forecast.Arima(SP500.arima, h=12)
summary(SP500.arima.forecasts1)
##
## Forecast method: ARIMA(0,0,0) with non-zero mean
##
## Model Information:
##
## Call:
## arima(x = SP500.sorted.ts, order = c(0, 0, 0))
##
## Coefficients:
## intercept
## 1630.7384
## s.e. 40.3643
##
## sigma^2 estimated as 135230: log likelihood = -608.08, aic = 1220.17
##
## Error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -1.398145e-13 367.7363 336.8832 -5.519743 22.11985 1.935423
## ACF1
## Training set 0.9656371
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Dec 2016 1630.738 1159.465 2102.012 909.9884 2351.488
## Jan 2017 1630.738 1159.465 2102.012 909.9884 2351.488
## Feb 2017 1630.738 1159.465 2102.012 909.9884 2351.488
## Mar 2017 1630.738 1159.465 2102.012 909.9884 2351.488
## Apr 2017 1630.738 1159.465 2102.012 909.9884 2351.488
## May 2017 1630.738 1159.465 2102.012 909.9884 2351.488
## Jun 2017 1630.738 1159.465 2102.012 909.9884 2351.488
## Jul 2017 1630.738 1159.465 2102.012 909.9884 2351.488
## Aug 2017 1630.738 1159.465 2102.012 909.9884 2351.488
## Sep 2017 1630.738 1159.465 2102.012 909.9884 2351.488
## Oct 2017 1630.738 1159.465 2102.012 909.9884 2351.488
## Nov 2017 1630.738 1159.465 2102.012 909.9884 2351.488
plot(SP500.arima.forecasts1)
SP500.arima<-arima(SP500.sorted.ts, c(0,1,0)) # this models is equivalent to ARMA(0,1,0)
SP500.arima.forecasts2 <- forecast.Arima(SP500.arima, h=12)
SP500.arima.forecasts2
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Dec 2016 2128.68 2056.647 2200.712 2018.516 2238.844
## Jan 2017 2128.68 2026.811 2230.549 1972.884 2284.476
## Feb 2017 2128.68 2003.916 2253.444 1937.870 2319.490
## Mar 2017 2128.68 1984.615 2272.745 1908.351 2349.009
## Apr 2017 2128.68 1967.610 2289.750 1882.345 2375.015
## May 2017 2128.68 1952.237 2305.123 1858.834 2398.526
## Jun 2017 2128.68 1938.100 2319.260 1837.213 2420.147
## Jul 2017 2128.68 1924.941 2332.419 1817.088 2440.272
## Aug 2017 2128.68 1912.582 2344.778 1798.187 2459.173
## Sep 2017 2128.68 1900.893 2356.467 1780.310 2477.050
## Oct 2017 2128.68 1889.775 2367.585 1763.306 2494.054
## Nov 2017 2128.68 1879.152 2378.208 1747.060 2510.300
plot(SP500.arima.forecasts2)
SP500.arima<-arima(SP500.sorted.ts, c(1,1,0)) # this models is equivalent to ARMA(1,1,0)
SP500.arima.forecasts3 <- forecast.Arima(SP500.arima, h=12)
SP500.arima.forecasts3
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Dec 2016 2131.013 2059.137 2202.889 2021.088 2240.938
## Jan 2017 2130.860 2032.482 2229.239 1980.404 2281.317
## Feb 2017 2130.870 2011.573 2250.168 1948.421 2313.320
## Mar 2017 2130.870 1993.820 2267.920 1921.270 2340.469
## Apr 2017 2130.870 1978.116 2283.623 1897.254 2364.486
## May 2017 2130.870 1963.883 2297.857 1875.485 2386.254
## Jun 2017 2130.870 1950.771 2310.969 1855.432 2406.307
## Jul 2017 2130.870 1938.551 2323.189 1836.743 2424.996
## Aug 2017 2130.870 1927.062 2334.678 1819.173 2442.567
## Sep 2017 2130.870 1916.187 2345.552 1802.541 2459.198
## Oct 2017 2130.870 1905.838 2355.902 1786.713 2475.027
## Nov 2017 2130.870 1895.943 2365.796 1771.581 2490.159
plot(SP500.arima.forecasts3)